/**
* 设备管理
 */
 <template>
  <div class="page-box h100 display-flex czbj">
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :qx="qx"
      :formJson="formJson"
      ref="dxtableRef"
      :czFun="czFun"
    ></dxtable>
  </div>
</template>
  <script lang='ts' setup>
import dxtable from "../../../components/util/dxtable.vue";
import { dxget, transferTimeYMD } from "../../../util/index";
import { useRouter, onBeforeRouteUpdate } from "vue-router";
import { NButton } from "naive-ui";
import {
  DeclareMeans,
  siteSoil,
  areas,
  statictype,
  Reviewtypes,
  sblxse,
} from "../../../util/beRelieved/index";
import { h, ref, reactive } from "vue";
import { quyu } from "../../../util/beRelieved/quyu";

import { hf, qurl } from "../../../util/index";
const cz = qurl();
let portUrl = "beRelieved/equipment";
let dataJson = [
  {
    title: "序号",
    width: 60,
    render(row, index) {
      return index + 1;
    },
  },
  {
    search: true,
    title: "场地名称",
    key: "SiteName",
    width: 120,
  },
  {
    search: true,
    title: "点位名称",
    ellipsis: {
      tooltip: true,
    },
    key: "name",
  },
  {
    title: "AED机柜编码",
    key: "coding",
    search: true,
    width: 120,
  },
  {
    title: "AED设备序列号",
    key: "serialNumber",
    search: true,
    width: 120,
  },
  {
    title: "AED有效期",
    key: "validity",
    search: true,
    width: 110,
  },
  {
    title: "现场执行任务",
    key: "FieldExecution",
    width: 110,
    search: true,
  },
  {
    title: "东纬，北纬",
    key: "longitude",
    width: 160,
    render(row) {
      return row.longitude + ",\n" + row.latitude;
    },
  },
  {
    title: "场地联系人",
    search: true,
    width: 100,
    key: "VenueContactPerson",
  },
  {
    title: "联系方式",
    width: 120,
    key: "contactway",
  },
  {
    title: "场地地址",
    width: 160,
    ellipsis: {
      tooltip: true,
    },
    render(row) {
      return getdizhi(row.district, row.street, row.detailedAddress);
    },
  },
  {
    title: "设备类型",
    width: 200,
    key: "type",
    search: true,
    type: "select",
    options: sblxse,
    value: parseInt(cz.type),
    render(row) {
      return sblxse.filter((a) => a.value == row.type)[0].label;
    },
  },
];
const getdizhi = (dt, st, detailedAddress) => {
  try {
    const district = quyu.filter((a) => a.value == dt)[0];
    const street = district.xiaji.filter((a) => a.value == st)[0].label;
    return district.label + street + detailedAddress;
  } catch (e) {
    return "-";
  }
};
let formJson = ref([
  {
    type: "input",
    title: "点位名称",
    key: "name",
  },
  {
    title: "AED机柜编码",
    key: "coding",
    type: "input",
  },
  {
    title: "AED设备序列号",
    key: "serialNumber",
    type: "input",
  },
  {
    title: "AED有效期",
    key: "validity",
    type: "input",
  },
  {
    title: "现场执行任务",
    key: "FieldExecution",
    type: "input",
  },
]);
const qx = {
  DeletePermissionID: "ManagementGroupdel", //删除
  EditPermissionIdentifier: "ManagementGroupbj", // 编辑
  NewPermissionIdentifier: "ManagementGroupxz", // 新建
  ViewPermissionID: "ManagementGroupck", // 查看
};

const czFun = {
  fun: (row) => {
    return h(
      NButton,
      {
        type: "info",
        quaternary: true,
        onClick: async (e) => {
          hf("ManagementGroupDetails", { id: row.id });
        },
      },
      "查看"
    );
  },
};
</script>
  <style scoped>
</style>